<% provide(:title, "Edit micropost") %>
<h1>Update your micropost</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(@micropost, html: { multipart: true }) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :content %>
<%= f.text_field :content, class: 'form-control' %>
<span class="picture">
<%= f.file_field :picture, accept: 'image/jpeg,image/gif,image/png' %>
</span>
<%= f.submit "Save changes", class: "btn btn-primary" %>
<% end %>
</div>
</div>
</div>

<script type="text/javascript">
$('#micropost_picture').bind('change', function() {
size_in_megabytes = this.files[0].size/1024/1024;
if (size_in_megabytes > 5) {
alert('Maximum file size is 5MB. Please choose a smaller file.');
}
});
</script>